import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'
import type { DataExportAO } from '/@/model/cn/core/tool/ao/DataExportAO'

import expressionParamService from '/@/api/cn/core/kpis/expressionParamService'

import type { ExpressionParam } from '/@/model/cn/core/kpis/eo/ExpressionParam'
import type { ExpressionParamQO } from '/@/model/cn/core/kpis/qo/ExpressionParamQO'
import type { ExpressionParamVO } from '/@/model/cn/core/kpis/vo/ExpressionParamVO'

interface ExpressionParamState {
}

export const useExpressionParamStore = defineStore({
  id: 'expressionParam',
  state: (): ExpressionParamState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<ExpressionParam>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.save(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<ExpressionParam>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.saveBatch(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<ExpressionParam>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.update(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<ExpressionParam>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.updateBatch(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<ExpressionParam>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.remove(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<ExpressionParam>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.removeBatch(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.count(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.pk(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.query(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.paging(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParamVO>> {
      return new Promise<Res<ExpressionParamVO>>((resolve, reject) => {
        expressionParamService.countVo(param).then((res: AxiosResponse<Res<ExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParamVO>> {
      return new Promise<Res<ExpressionParamVO>>((resolve, reject) => {
        expressionParamService.pkVo(param).then((res: AxiosResponse<Res<ExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParamVO>> {
      return new Promise<Res<ExpressionParamVO>>((resolve, reject) => {
        expressionParamService.queryVo(param).then((res: AxiosResponse<Res<ExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<ExpressionParamQO>): Promise<Res<ExpressionParamVO>> {
      return new Promise<Res<ExpressionParamVO>>((resolve, reject) => {
        expressionParamService.pagingVo(param).then((res: AxiosResponse<Res<ExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataImport(param: Param<string>): Promise<Res<ExpressionParam>> {
      return new Promise<Res<ExpressionParam>>((resolve, reject) => {
        expressionParamService.dataImport(param).then((res: AxiosResponse<Res<ExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataExport(param: Param<DataExportAO<ExpressionParamQO>>): Promise<Res<string>> {
      return new Promise<Res<string>>((resolve, reject) => {
        expressionParamService.dataExport(param).then((res: AxiosResponse<Res<string>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useExpressionParamStoreWithout() {
  return useExpressionParamStore(store)
}
